CUBE CONNECT Edition Help

Examples

This section contains examples showing different ways to run the Public Transport program. Examples cover:

Public transport network development

Example 1: Preparing a public transport network

This example prepares a public transport network from:

  • Network program-produced network, providing the basic infrastructure of zones, nodes and links (input with NETI)
  • Line data (input with LINEI[1])

  • Public Transport system data (input with SYSTEMI)

  • Factor data for route-enumeration and route-evaluation processes (input with FACTORI)

  • GENERATE statements that generate the nontransit network.

Parameter TRANTIME provides the location of transit time in the link record.

The script explicitly codes the DATAPREP phase. You can only code GENERATE statements in this phase.

This script produces a public transport network, containing validated input and the described generated components. You can save this network and for subsequent use by the Public Transport program for route enumeration, route evaluation, skimming, loading, and loading analyses. You can also display the network in CUBE.

;Prepare a Public Transport Network
RUN PGM = PUBLIC TRANSPORT

;Output files
FILEO REPORTO = LDPRN00A.PRN
FILEO NETO = LDNET00B.NET

;Input Files
FILEI SYSTEMI = PTSYSTEM.PTS
FILEI FACTORI[1] =FACTORLD.FAC
FILEI LINEI[1] = ISL_PTLINES.LIN
FILEI NETI = LDHWN00A.NET

;Globals
PARAMETERS TRANTIME = li.TrnsTime

PHASE=DATAPREP
  ;generate access/egress links
   list='\nGenerate Zone Access/Egress Legs'
   GENERATE,
     COST=li.WalkTime,
     MAXCOST[1]=16*20,
     LIST=T,
     NTLEGMODE=33,
     INCLUDELINK = li.WalkTime>0

   ;generate xfer non-transit legs
   list='\nGenerate Transfer Legs'
   GENERATE,
     COST=li.WalkTime,
     MAXCOST[1]=16*15,
     LIST=T,
     NTLEGMODE = 34,
     ONEWAY=F,
     INCLUDELINK = li.WalkTime>0,
     FROMNODE=26-4000, TONODE=26-4000
ENDPHASE
ENDRUN

Example 2: Preparing a public transport network from TRIPS link data

This example prepares a public transport network from TRIPS- formatted link data. You can input the TRIPS network directly into the Network program to prepare the base network.

The script uses three phases:

  • NODEREAD reports the number, and X- and Y-coordinates of all nodes in the input network.

  • LINKREAD calculates walk and transit times for all links in the network. TRIPS networks have links, identified by link type, that are "walk" only, "transit" only, or "both" walk and transit. The LINKREAD phase produces walk and transit time fields for each link. For links where only one activity can take place, the other field contains a zero.

  • DATAPREP produces some diagnostics and generates access, egress, and transfer links. The generation process only includes links with a walk link-time greater than zero.

;Prepare a Public Transport Network from TRIPS data
RUN PGM = PUBLIC TRANSPORT

;Output files
FILEO NETO =LDNET00B.NET
FILEO NTLEGO = LDNTL00A.NTL
FILEO REPORTO =LDPRN00A.PRN

;Input files
FILEI LINEI[1] = \ISL_PTLINES.LIN
FILEI NETI = LDHWN00A.NET
FILEI FACTORI[1] = FACTORLD.FAC,
LIST=T
FILEI SYSTEMI = PTSYSTEM.PTS

;GLOBALS
PARAMETERS TRANTIME = li.TrnsTime

;NODEREAD phase loops over nodes.  Can access network node variables
N.xxx,

;and generate node variables Nw.xxx.
PHASE=NODEREAD
  print list=ni.n, ni.x, ni.y
ENDPHASE

;LINKREAD phase loops over links. Can access network link variables L.xxx and
;generate link variables Lw.xxx.
PHASE=LINKREAD
  ;this phase is used to generate walk and transit times for
  ;the links of a TRIPS Public Transport network
  ;convert TRIPS distance and speed/time fields from 100dths to units
  lw.RDIST=li.DISTANCE/100.
  lw.RSPDTIME=li.SPDTIME/100.

  ;links with LT codes 10, 28,29,31,32 are walk only
  lw.WalkTimePT = 0
  if(li.LType == 10,28,29,31,32 && li.STFLAG == 'S')
    lw.WalkTimePT = 60.* lw.RDIST/lw.RSPDTIME
  elseif(li.ltype == 10,28,29,30,31,32 && li.STFLAG == 'T')
    lw.WalkTimePT=lw.RSPDTIME
  elseif(li.LType == 18)
    lw.WalkTimePT = 60.* lw.RDIST/4.
  endif

  if(li.LType == 10,18,28,29,31,32)
    lw.TrnsTime = 0.0
  else
    lw.TrnsTime = lw.RSPDTIME
  endif

  if(lw.TrnsTime != 0.0 && li.STFLAG == 'S')
    lw.TrnsTime =(60.* lw.RDIST/lw.RSPDTIME)
  endif

  list =li.A(9),li.B(9), li.DISTANCE(8.2), lw.RDIST(8.2)
li.WalkTime(8.2),
  lw.WalkTimePT(8.2), li.TrnsTime(8.2), lw.TrnsTime(8.2), li.LType(3),
li.STFLAG
ENDPHASE
;DATAPREP is the non-transit leg generation/input phase.
;Network and line variables can be
;accessed and manipulated and non-transit legs are generated.
PHASE=DATAPREP
  ;Count & report number of transit only, walk only and both walk and
  ;transit links.  If no walk or transit links, or links with invalid
  ;time, the run is aborted with a suitable message
  ;(This demonstrates the use of the command LINKLOOP which loops over links)
  WalkLnkCnt = 0
  TrnsLnkCnt = 0
  BothLnkCnt = 0
  ErrLnkCnt = 0

   LINKLOOP
     if(lw.WalkTimePT > 0.0 && lw.TrnsTime == 0.0)
       WalkLnkCnt = WalkLnkCnt+1
     elseif(lw.WalkTimePT == 0.0 && lw.TrnsTime > 0.0)
       TrnsLnkCnt = TrnsLnkCnt+1
     elseif(lw.WalkTimePT > 0.0 && lw.TrnsTime > 0.0)
       BothLnkCnt = BothLnkCnt+1
     else
       ErrLnkCnt = ErrLnkCnt+1
       PRINT LIST = li.a, li.b, lw.WalkTimePT, lw.TrnsTime
     endif
   ENDLINKLOOP
   PRINT LIST = '\nNumber of walk only links = ', WalkLnkCnt,
               '\nNumber of transit only links = ', TrnsLnkCnt,
               '\nNumber of walk and transit links = ', BothLnkCnt,
               '\n'
   ;Note if and 'if' statement does not fit on one line and closing 'endif'
   ;is required
   if(WalkLnkCnt==0 && BothLnkCnt==0)abort msg = No Walk links in the Network
   if(TrnsLnkCnt==0 && BothLnkCnt==0)abort msg = No Transit links in the Network
   if(ErrLnkCnt> 0)abort msg = Links with invalid time/speeds in Network
   ;Generate access/egress links
   list='\nGenerate Zone Access/Egress Legs  '
   GENERATE,
      COST=lw.WalkTimePT,
      MAXCOST[1]=16*20,
      LIST=T,
      NTLEGMODE = 33,
      INCLUDELINK = lw.WalkTimePT>0
   ;Generate xfer non-transit legs
   list='\nGenerate Transfer Legs  '
   GENERATE,
      COST=lw.WalkTimePT,
      MAXCOST[1]=16*15,
      LIST=T,
      NTLEGMODE = 34,
      ONEWAY=F,
       INCLUDELINK = lw.WalkTimePT>0,
      FROMNODE=26-4000, TONODE=26-4000
 ENDPHASE
ENDRUN

Public transport skimming

This example extracts skim or level-of-service matrices, reports them, and saves them to the file indicated by MATO[1].

A previously prepared public transport network is input with NETI.

You must enumerate and evaluate routes before extracting skims. The ROUTEO file indicates that the script will enumerate routes. (Alternatively, you could input routes prepared in an earlier run with ROUTEI.)

The SKIMIJ phase selects skimming, which the script must explicitly code. Skim functions select the skims for extraction. (Skimming automatically invokes the route-evaluation process.)

The optional MATO phases reports skims.

;Skim Route Attributes from a previously prepared Public Transport network RUN PGM=PUBLIC TRANSPORT
;Output files
FILEO REPORTO = LDPRN00A.PRN
FILEO MATO[1] = LDMAT00E.MAT,
MO=2-9,11-23, NAME = Compcost, ValOfChoice, IWAITA, XWAITA, IWAITP,
XWAITP,
TIMEAAM, TIMEATM, TIMEPAM, TIMEPTM, TIMEPNTM, BRDPENAM, BRDPENTM,
XFERPENAM, XFERPENTM, DISTAM, DISTTM, DISTNTM, BRDINGSAM, BRDINGSTM,
BESTJRNY,
=22*2
FILEO ROUTEO[1] = LDRTE00B.RTE
;Input files
FILEI NETI = LDNET00B.NET
;SKIMIJ loops over IJ pairs. Skim are saved in working matrices.
;Routes are enumerated, evaluated and skimmed before this phase.
PHASE=SKIMIJ
   MW[2]=COMPCOST(0)                 ;composite cost
   MW[3]=ValOfChoice(0)              ;value of choice
   MW[4]=IWAITA(0)                   ;initial wait time, actual, avg
   MW[5]=XWAITA(0)                   ;transfer wait time, actual, avg
   MW[6]=IWAITP(0)                   ;initial wait time, perceived, avg
   MW[7]=XWAITP(0)                   ;transfer wait time, perceived, avg

   MW[8]=TIMEA(0,ALLMODES)           ;time for all modes, actual
   MW[9]=TIMEA(0,1,7,8,11)           ;in-vehicle time for transit modes,
actual, avg
   MW[11]=TIMEP(0,ALLMODES)          ;time for all modes, perceived, avg
   MW[12]= TIMEP(0,TMODES)           ;in-vehicle time for transit modes,
perceived,

                                     ;avg
   MW[13]= TIMEP(0,33,-35)           ;walk/ride time for non-transit modes,
                                     ;perceived, avg

   MW[14]= BRDPEN(0,ALLMODES)        ;boarding penalty for all modes, avg
   MW[15]= BRDPEN(0,TMODES)          ;boarding penalty for transit modes,
avg
   MW[16]= XFERPENA(0, ALLMODES)     ;transfer penalty for all modes,
actual, avg
   MW[17]= XFERPENP(0, 1,7,-8,11)    ;transfer penalty for transit modes,
perceived,
                                     ;avg

   MW[18]= DIST(0,ALLMODES)          ;distance for all modes, avg
   MW[19]= DIST(0,TMODES)            ;in-vehicle distance for transit
modes, avg
   MW[20]= DIST(0,NTMODES)           ;walk/ride distance for non-transit
modes, avg
   MW[21]= BRDINGS(0,ALLMODES)       ;number of boardings for all modes,
avg
   MW[22]= BRDINGS(0,TMODES)         ;number of boardings for transit
modes, same as
                                     ;above, avg

   MW[23]=BESTJRNY                   ;best travel time

ENDPHASE

;MATO loops over J for each I. All skims extracted above are reported
PHASE=MATO
  if(ROWSUM(2)  > 0) PRINTROW mw=2 TITLE='Compcost', BASE1=T, FORM=10.2
  if(ROWSUM(3)  > 0) PRINTROW mw=3  TITLE='ValOfChoice', BASE1=T,
FORM=10.2
if(ROWSUM(4)  > 0) PRINTROW mw=4  TITLE='IWAITA', BASE1=T, FORM=10.2
  if(ROWSUM(5)  > 0) PRINTROW mw=5  TITLE='XWAITA', BASE1=T, FORM=10.2
  if(ROWSUM(6)  > 0) PRINTROW mw=6  TITLE='IWAITP', BASE1=T, FORM=10.2
  if(ROWSUM(7)  > 0) PRINTROW mw=7  TITLE='XWAITP', BASE1=T, FORM=10.2
  if(ROWSUM(8)  > 0) PRINTROW mw=8  TITLE='TIMEA ALLMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(9)  > 0) PRINTROW mw=9  TITLE='TIMEA TMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(11)  > 0) PRINTROW mw=11  TITLE='TIMEP ALLMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(12)  > 0) PRINTROW mw=12  TITLE='TIMEP TMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(13)  > 0) PRINTROW mw=13  TITLE='TIMEP NTMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(14)  > 0) PRINTROW mw=14  TITLE='BRDPEN ALLMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(15)  > 0) PRINTROW mw=15  TITLE='BRDPEN TMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(16)  > 0) PRINTROW mw=16  TITLE='XFERPEN ALLMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(17)  > 0) PRINTROW mw=17  TITLE='XFERPEN TMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(18)  > 0) PRINTROW mw=18  TITLE='DIST ALLMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(19)  > 0) PRINTROW mw=19  TITLE='DIST TMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(20)  > 0) PRINTROW mw=20  TITLE='DIST NTMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(21)  > 0) PRINTROW mw=21  TITLE='BRDINGS ALLMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(22)  > 0) PRINTROW mw=22  TITLE='BRDINGS TMODES', BASE1=T,
FORM=10.2
  if(ROWSUM(23) > 0) PRINTROW mw=23 TITLE='BESTJRNY', BASE1=T, FORM=10.2
ENDPHASE
ENDRUN

Public transport loading

This example loads a trip matrix, input with MATI[1], on to a previously prepared public transport network.

You must enumerate and evaluate routes before loading trips. The ROUTEO file indicates that the script will enumerate routes. (Alternatively, you can input routes prepared in an earlier run with ROUTEI.)

TRIPSIJ[1] indicates that loading is to be performed. (Loading automatically invokes the route-evaluation process.)

The REPORT statement selects two loading reports—line summary and passenger loading.

/*Load a previously built PT Network & Produce Loading
Analyses Reports */
RUN PGM=PUBLIC TRANSPORT
;Output Files
FILEO NETO = LDNET00C.NET
FILEO ROUTEO[1] =LDRTE00C.RTE
FILEO REPORTO = LDPRN00B.PRN
;Input files
FILEI MATI[1] = OD.MAT
FILEI NETI =LDNET00B.NET
;Globals this invokes Loading
PARAMETERS TRIPSIJ[1] = MI.1.1
;Selection of Loading Reports
REPORT LINES=T, SORT=MODE, LINEVOLS=T, STOPSONLY=T,
SKIP0=T
ENDRUN

Public transport user classes

This example prepares a public transport network, enumerates and evaluates routes, skims, and loads for two user classes. Essentially, this example performs the main functions of the Public Transport program for two user classes.

First, the script develops the public transport network for both user classes from:

  • Network input on NETI

  • Lines input on LINEI[1]

  • Factors input on FACTORI[1] and FACTORI[2]

  • Public Transport system data input on SYSTEMI

  • GENERATE statements for generating the nontransit network

The script codes the DATAPREP phase, a mandatory phase for public transport network development.

Next, the script performs the following functions for each user class:

  • Route enumeration — Saves routes on ROUTEO[1] and ROUTEO[2].

  • Route evaluation

  • Skimming — Extracts composite and value-of-choice skims, saves on MATO[1] and MATO[2], and reports.

  • Loading — Loads trip matrices input on any MATI file (not necessarily the one subscripted by the user class) to the evaluated routes.

The script codes the MATO phase to report the output skim matrices.

Finally, the script saves a public transport network containing the results of the loadings for both user classes to NETO. You can display the results with CUBE.

;Generate Non-transit network, Enumerate, Evaluate Routes,
Skim and Load for two User Classes.
RUN PGM=PUBLIC TRANSPORT

:Output Files
FILEO REPORTO = LDPRN00A.PRN
FILEO ROUTEO[2] = LDRTE00D.RTE
FILEO ROUTEO[1] = LDRTE00A.RTE
FILEO NETO = LDNET00E.NET

:input
FILEI MATI[2] = MSMAT00B.MAT
FILEI MATI[1] = MSMAT00B.MAT
FILEI SYSTEMI = PTSYSTEM.PTS
FILEI FACTORI[2] =FACTORUS2.FAC
FILEI FACTORI[1] = FACTORUS1.FAC
FILEI LINEI[1] = ISL_PTLINES.LIN
FILEI NETI =LDHWN00A.NET

;Globals
PARAMETERS TRANTIME=li.TrnsTime
PARAMETERS USERCLASSES=1,2
PARAMETERS TRIPSIJ[1] = Mi.01.1
PARAMETERS TRIPSIJ[2] = Mi.02.1

PHASE=DATAPREP
   ;generate access/egress links
     list='\nGenerate Zone Access/Egress Legs  '
     GENERATE,
       COST=li.WalkTime,
       MAXCOST[1]=16*20,
       LIST=T,
       NTLEGMODE = 33,
       INCLUDELINK = li.WalkTime>0
     ;generate xfer non-transit legs
     list='\nGenerate Transfer Legs  '
     GENERATE,
       COST=li.WalkTime,
       MAXCOST[1]=16*15,
       LIST=T,
       NTLEGMODE = 34,
       ONEWAY=F,
       INCLUDELINK = li.WalkTime>0,
       FROMNODE=26-4000, TONODE=26-4000
ENDPHASE

;Routes are enumerated, evaluated, skimmed and loaded for each user class
;SKIMIJ loops over IJ pairs. Skims are saved in working matrices in this
phase
PHASE=SKIMIJ
   MW[1]=COMPCOST(0)             ;composite cost
   MW[2]=ValOfChoice(0)          ;value of choice
ENDPHASE
;MATO loops over J for each I.  Skims are reported for each user class
PHASE=MATO
  if(ROWSUM(1)  > 0) PRINTROW mw=1 TITLE='Compcost', BASE1=T, FORM=10.2
  if(ROWSUM(2)  > 0) PRINTROW mw=2  TITLE='ValOfChoice', BASE1=T,
FORM=10.2
ENDPHASE
ENDRUN

Public transport crowding

In the below example, the PT program will generate 10 STOP2STOP output files. They are automatically named as "Stop2StopResults_1.DBF", "Stop2StopResults_2.DBF", … , "Stop2StopResults_9.DBF", "Stop2StopResults.DBF", i.e. the numbers 1, 2, …, 9 are corresponding to each individual iteration, and the last iteration file does not have the iteration number appended. These files are likely to be very large for large networks.

RUN PGM=PUBLIC TRANSPORT PRNFILE="{SCENARIO_DIR}\PTLOADING.PRN"
;Output File
FILEO STOP2STOPO = "{SCENARIO_DIR}\STOP2STOP.DBF",
      N=26-10000 ACCUMULATE=FIRSTLAST FORMAT=CSV
FILEO NETO = "C:\Cubetown\MODEL\PT_{SCENARIO_CODE}.NET"
FILEO REPORTO = "C:\Cubetown\MODEL\REPORTO>PRN"
FILEO ROUTEO[1] = "C:\Cubetown\MODEL\ROUTEO.RTE"
      I=1 J=2 REPORTI=1 REPORTJ=2 TRACEI=1 TRACEJ=2
FILEO MATO[1] = "C:\Cubetown\MODEL\PTSKIMS.MAT",
      MO=1, NAME = 'PT CompCosts'

;Input Files
FILEI NETI = "C:\Cubetown\MODEL\LOADED_{SCENARIO_CODE}.NET"
FILEI LINEI[1] = "C:\Cubetown\MODEL\TRANSIT_{SCENARIO_COD}.LIN"
FILEI SYSTEMI = "C:\Cubetown\MODEL\CUBETOWN.PTS"
FILEI FAREI = "C:\Cubetown\MODEL\CUBETOWN.FAR"
FILEI FACTOR[1] = "C:\Cubetown\MODEL\CUBETOWN.FAC"

PARAMETERS TRANTIME = LW.TRANTIME
CROWDMODEL APPLY=T, ADJUSTLINK=T, ADJUSTWAIT=T, ITERATIONS=10, PERIOD=60, REPORTIJ=T,
           TRACEIJ=T, RDIFF=T, RMSE=T, STOP2STOP=T, SKIMS=T